﻿@model WebChat.Models.ChannelFormViewModel

<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Chatroom</legend>

        <div class="editor-label">
            @Html.LabelFor(model => model.room.Name)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.room.Name)
            @Html.ValidationMessageFor(model => model.room.Name)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.room.MaximumUsers)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.room.MaximumUsers)
            @Html.ValidationMessageFor(model => model.room.MaximumUsers)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.room.IsPublic)
        </div>
        
        <div class="editor-field">
            @Html.RadioButton("room.IsPublic", "Yes") Yes 
            @Html.RadioButton("room.IsPublic", "No", true)  No
            @Html.ValidationMessageFor(model => model.room.IsPublic)
        </div>
        
        <div id="PermittedUsers">
        <p>Hei</p>
          @Html.ListBox("Users", Model.user)     
        </div>
        <script type="text/javascript">
            $("input[name='room.IsPublic']").change(function () {
                $("#PermittedUsers").toggle(this.value == "No");
            });
        </script>
        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
